package com.wang.exception_homework.hw5;

import java.util.Scanner;

public class Demo {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入年龄：");
        int age = sc.nextInt();
        try {
            if (age < 1 || age > 100){
                throw new Exception("年龄必须在1-100之间！");
            }
            System.out.println("你的年龄：" + age);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
